"use strict";

var path = require("path");
var gulp = require("gulp");
var packageJson = require(path.join(__dirname, "..", "..", "package.json"));
var source = path.join(__dirname, "..", "..", "src", "html" , "index.html");
var build = path.join(__dirname, "..", "..", "prod");
var ext = "html";

/**
 * Copy index.html from source to prod.
 * Preprocess variables depending of environment.
 *
 * @method prod:html
 */
function html() {
  var plugins = this.opts.plugins;
  return gulp.src(source)
    .pipe(plugins.preprocess({
      extension: ext,
      context: {
        NODE_ENV: "production",
        NAME: packageJson.name,
        VERSION: packageJson.version
      }
    }))
    .pipe(gulp.dest(build, {prefix : 2}));
}
module.exports = html;
